#!usr/bin/env python  
# -*- coding:utf-8 -*-
""" 
@author:robot
@file: HJ28.py 
@version:
@time: 2023/05/22
https://www.nowcoder.com/practice/b9eae162e02f4f928eac37d7699b352e?tpId=37&tqId=21251&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fdifficulty%3D5%26page%3D1%26pageSize%3D50%26search%3D%26tpId%3D37%26type%3D37&difficulty=5&judgeStatus=undefined&tags=&title=

输入：
4
2 5 6 13

输出：
2
"""
import math


def check(num):
    for i in range(2, int(math.sqrt(num)) + 2):
        if num % i == 0:
            return False
    return True


def find(odd, visited, choose, evens):
    """

    :param odd: 偶数
    :param visited: 用来存放当前奇数和偶数是否已经配过对，长度为len(evens)
    :param choose: 用来存放当前和这个奇数配对的那个偶数，长度为len(evens)
    :param evens: 奇数
    :return:
    """
    # 从偶数里取值
    for j, even in enumerate(evens):
        # 如果奇数+偶数为素数，且没有匹配过
        if check(odd + even) and not visited[j]:
            # visited[j]被置为True
            visited[j] = True
            # 如果当前奇数没有和任何一个偶数现在已经配对，
            # 那么认为找到一组可以连接的，
            # 如果当前的奇数已经配对，那么就让那个与之配对的偶数断开连接，
            # 让他再次寻找能够配对的奇数
            if choose[j] == 0 or find(choose[j], visited, choose, evens):
                choose[j] = odd  # 当前奇数已经和当前的偶数配对
                return True
    return False  # 如果当前不能配对则返回False


while True:
    try:
        num = int(input())
        a = input()
        a = a.split()
        for i in range(len(a)):
            a = list(map(int, a))

        count = 0

        # 奇数
        evens = []
        # 偶数
        odds = []
        for i in a:
            if i % 2 == 0:
                odds.append(i)
            else:
                evens.append(i)
        # choose用来存放当前和这个奇数配对的那个偶数
        choose = [0] * len(evens)
        for odd in odds:
            # visit用来存放当前奇数和偶数是否已经配过对
            visited = [False] * len(evens)
            if find(odd, visited, choose, evens):
                count += 1
        print(count)
    except:
        break
